package ai.tubes.iris;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SolveFromFormActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.inputdata);
		
		
		alertDialog = new AlertDialog.Builder(this).create();
		
		
//		mLaring = (TextView)findViewById(R.id.txtlaring);
//		mTiroid = (TextView)findViewById(R.id.txttiroid);
//		mBronkus = (TextView)findViewById(R.id.txtbronkus);
//		mAppendiks = (TextView)findViewById(R.id.txtappendiks);
//		mPankreas = (TextView)findViewById(R.id.txtpankreas);
//		mHati = (TextView)findViewById(R.id.txthati);
//		mEmpedu = (TextView)findViewById(R.id.txtempedu);
//		mGinjal = (TextView)findViewById(R.id.txtginjal);
//		mDada = (TextView)findViewById(R.id.txtdada);
//		mParu = (TextView)findViewById(R.id.txtparu);
//		mBronkialis = (TextView)findViewById(R.id.txtbronkialis);
//		mJantung = (TextView)findViewById(R.id.txtjantung);
//		mLimpa = (TextView)findViewById(R.id.txtlimpa);
//		mKolonnaik = (TextView)findViewById(R.id.txtkolonnaik);
//		mKolonturun = (TextView)findViewById(R.id.txtkolonturun);
//		mUsusKecil = (TextView)findViewById(R.id.txtususkecil);
//		mKolonSigmoid = (TextView)findViewById(R.id.txtkolonsigmoid);
//		mUsusBuntu = (TextView)findViewById(R.id.txtususbuntu);
//		mLambung = (TextView)findViewById(R.id.txtlambung);
		
		
		

		mCheck	= (Button)findViewById(R.id.buttoncek);
		mCheck.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				
				//set semua static variablenya
				
				String LaringText = ((EditText)findViewById(R.id.txtlaring)).getText().toString();
				String TiroidText = ((EditText)findViewById(R.id.txttiroid)).getText().toString();
				String BronkusText = ((EditText)findViewById(R.id.txtbronkus)).getText().toString();
				String AppendiksText = ((EditText)findViewById(R.id.txtappendiks)).getText().toString();
				String PankreasText = ((EditText)findViewById(R.id.txtpankreas)).getText().toString();
				String HatiText = ((EditText)findViewById(R.id.txthati)).getText().toString();
				String EmpeduText = ((EditText)findViewById(R.id.txtempedu)).getText().toString();
				String GinjalText = ((EditText)findViewById(R.id.txtginjal)).getText().toString();
				String DadaText = ((EditText)findViewById(R.id.txtdada)).getText().toString();
				String ParuText = ((EditText)findViewById(R.id.txtparu)).getText().toString();
				String BronkialisText = ((EditText)findViewById(R.id.txtbronkialis)).getText().toString();
				String JantungText = ((EditText)findViewById(R.id.txtjantung)).getText().toString();
				String LimpaText = ((EditText)findViewById(R.id.txtlimpa)).getText().toString();
				String KolonnaikText = ((EditText)findViewById(R.id.txtkolonnaik)).getText().toString();
				String KolonturunText = ((EditText)findViewById(R.id.txtkolonturun)).getText().toString();
				String UsuskecilText = ((EditText)findViewById(R.id.txtususkecil)).getText().toString();
				String KolonsigmoidText = ((EditText)findViewById(R.id.txtkolonsigmoid)).getText().toString();
				String UsusbuntuText = ((EditText)findViewById(R.id.txtususbuntu)).getText().toString();
				String LambungText = ((EditText)findViewById(R.id.txtlambung)).getText().toString();
				
				if((!LaringText.equals(""))&&(!TiroidText.equals(""))&&(!BronkusText.equals(""))&&(!AppendiksText.equals(""))&&(!PankreasText.equals(""))&&(!HatiText.equals(""))&&(!EmpeduText.equals(""))&&(!GinjalText.equals(""))&&(!DadaText.equals(""))&&(!ParuText.equals(""))&&(!BronkialisText.equals(""))&&(!JantungText.equals(""))&&(!LimpaText.equals(""))&&(!KolonnaikText.equals(""))&&(!KolonturunText.equals(""))&&(!UsuskecilText.equals(""))&&(!KolonsigmoidText.equals(""))&&(!UsusbuntuText.equals(""))&&(!LambungText.equals("")))
				{
					/*Untuk debugging*/
//					GlobalVariable.mLaring = new Float(2) ;
//					GlobalVariable.mTiroid =  new Float(2);
//					GlobalVariable.mBronkus =  new Float(2);
//					GlobalVariable.mAppendiks = new Float(2);
//					GlobalVariable.mPankreas = new Float(2);
//					GlobalVariable.mHati = new Float(2);
//					GlobalVariable.mEmpedu = new Float(2);
//					GlobalVariable.mGinjal = new Float(2);
//					GlobalVariable.mDada = new Float(2);
//					GlobalVariable.mParu = new Float(2);
//					GlobalVariable.mBronkialis = new Float(2);
//					GlobalVariable.mJantung = new Float(2);
//					GlobalVariable.mLimpa = new Float(2);
//					GlobalVariable.mKolonnaik = new Float(2);
//					GlobalVariable.mKolonturun = new Float(2);
//					GlobalVariable.mUsusKecil = new Float(2);
//					GlobalVariable.mKolonSigmoid = new Float(2);
//					GlobalVariable.mUsusBuntu = new Float(2);
//					GlobalVariable.mLambung = new Float(2);					
					
					GlobalVariable.mLaring = new Float(LaringText) ;
					GlobalVariable.mTiroid =  new Float(TiroidText);
					GlobalVariable.mBronkus =  new Float(BronkusText);
					GlobalVariable.mAppendiks = new Float(AppendiksText);
					GlobalVariable.mPankreas = new Float(PankreasText);
					GlobalVariable.mHati = new Float(HatiText);
					GlobalVariable.mEmpedu = new Float(EmpeduText);
					GlobalVariable.mGinjal = new Float(GinjalText);
					GlobalVariable.mDada = new Float(DadaText);
					GlobalVariable.mParu = new Float(ParuText);
					GlobalVariable.mBronkialis = new Float(BronkialisText);
					GlobalVariable.mJantung = new Float(JantungText);
					GlobalVariable.mLimpa = new Float(LimpaText);
					GlobalVariable.mKolonnaik = new Float(KolonnaikText);
					GlobalVariable.mKolonturun = new Float(KolonturunText);
					GlobalVariable.mUsusKecil = new Float(UsuskecilText);
					GlobalVariable.mKolonSigmoid = new Float(KolonsigmoidText);
					GlobalVariable.mUsusBuntu = new Float(UsusbuntuText);
					GlobalVariable.mLambung = new Float(LambungText);

					startActivity(new Intent(SolveFromFormActivity.this.getApplicationContext(), ResultActivity.class));
				}
				else
				{
					alertDialog.setMessage("Please input all parameter first");
					alertDialog.show();
				}
				
				
				/*Untuk debugging*/
//				ai.tubes.iris.knowledge.inferenceengine coba = new ai.tubes.iris.knowledge.inferenceengine();				
//				
//				System.out.println(coba.InferenceStatus("Empedu", (float) 1));
//				System.out.println(coba.InferenceStatus("Empedu", (float) 2.3));
//				coba.changeInferenceStatus("Empedu", (float) 123, (float) 245);
//				coba.writeInferenceFile();
//
//				System.out.println(coba.getLearningData("Jantung", "Baik"));
//				System.out.println(coba.getLearningData("Jantung", "Buruk"));
//				System.out.println(coba.getLearningData("Empedu", "Baik"));
//				coba.addLearningData("Jantung", "Baik", (float) 3.2);
//				coba.addLearningData("Jantung", "Baik", (float) 2.2);
//				coba.addLearningData("Jantung", "Baik", (float) 100.2);
//				System.out.println("--------------------------------------");
//				System.out.println(coba.getLearningData("Jantung", "Baik"));
//				System.out.println(coba.getLearningData("Jantung", "Buruk"));
//				System.out.println(coba.getLearningData("Empedu", "Baik"));

				
			}
		});
	}
	
	AlertDialog alertDialog;
	public static final int REQUEST_CODE = 102;
	private Button mCheck;
	//private TextView mLaring,mTiroid,mBronkus,mAppendiks,mPankreas,mHati,mEmpedu,mGinjal,mDada,mParu,mBronkialis,mJantung,mLimpa,mKolonnaik,mKolonturun,mUsusKecil,mKolonSigmoid,mUsusBuntu,mLambung;
	
	
}
